package com.hr.reactive.operators;

import com.hr.reactive.common.Utils;
import reactor.core.publisher.Flux;

/**
 * @author huran
 *  handle案例
 */
public class Lec01Handle {
    public static void main(String[] args) {
   Flux.range(1, 10).
           filter(i->i!=7).
           handle((item,sink)->{
       switch (item){
           case 1->sink.next(-2);
           case 2->{}
           case 7->sink.error(new RuntimeException("oops"));
           default -> sink.next(item);
       }
   }).cast(Integer.class).subscribe(Utils.subscriber());

   }
}
